package com.itheima.jianbing;

public class Foodie implements Runnable{
    @Override
    public void run() {
        //死循环  可劲在这吃  到数了 就不吃了
        while (  Desk.count>0){
            synchronized (Desk.obj) {
                //判断是否有
                if(Desk.flag){
                    //有  吃
                    System.out.println("吃货正在吃煎饼...吃完了");
                    //改状态
                    Desk.flag=false;
                    Desk.count--;
                    //叫大爷继续做
                    Desk.obj.notifyAll();
                }else{//没有  等着
                    try {
                        Desk.obj.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }


        }




    }
}
